<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>我的发布</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- layUI的核心CSS文件 -->
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/css/layui.css"/>
    <!-- layUI的核心JS文件 -->
    <script src="${pageContext.request.contextPath}/static/layui-v2.5.7/layui/layui.js" type="text/javascript"
            charset="UTF-8"></script>
    <script src="${pageContext.request.contextPath}/static/script/jquery-1.7.2.js" charset="UTF-8"></script>
<%--        回到顶部的样式--%>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/static/css/toTop.css">
</head>
<body>

<%--回到顶部--%>
<i class="layui-icon layui-icon-up toTop"></i>
<script src="${pageContext.request.contextPath}/static/js/toTop.js">
</script>

<script>
    layui.use('element', function () {
        let element = layui.element;
    });
</script>
<!-- 头部导航栏 -->
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><a style="color: #009688;">龙洞闲置购物系统</a></div>

        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item">
                <a href="ShowALLGoods">首页</a>
            </li>

            <li class="layui-nav-item layui-this" style="user-select: none">
                我的发布
            </li>
        </ul>
        <%@include file="../common/head.jsp" %>
    </div>
</div>


<div class="layui-tab-content">
    <!-- 我发布的商品 -->
    <div class="layui-tab-item layui-show">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 25px">
            <!-- 种类名称 -->
            <legend style="margin-left: 50px;">我的发布</legend>
        </fieldset>

        <div class="layui-row">
            <div class="layui-col-md10">
                <table class="layui-table" style="text-align: center">
                    <colgroup>
                        <col width="50">
                        <col width="200">
                        <col width="80">
                        <col width="180">
                        <col width="300">
                        <col width="100">
                        <col width="80">
                        <col width="80">
                    </colgroup>
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>商品</th>
                        <th>类别</th>
                        <th>发布时间</th>
                        <th>商品描述</th>
                        <th>状态</th>
                        <th colspan="2">操作</th>
                    </tr>
                    </thead>
                    <%-- 主体部分 --%>
                    <tbody>
                    <tr>
                        <c:if test="${goodsPublish.size() == 0}">
                            <td colspan="8" style="text-align: center;height: 100px;">还没有发布过商品哦~</td>
                        </c:if>
                        <c:forEach var="goods1" items="${goodsPublish}">
                            <%--商品号--%>
                        <td>
                                ${goods1.gid}
                        </td>
                            <%--图片、商品名--%>
                        <td style="text-align: center">
                            <c:if test="${goods1.gimg_path==null}">
                                <img src="${pageContext.request.contextPath}/static/images/white1.jpg"
                                     alt="图片加载失败">
                            </c:if>
                            <c:if test="${goods1.gimg_path!=null}">
                                <img src="${goods1.gimg_path}"
                                     alt="图片加载失败">
                            </c:if>
                            <br>
                                ${goods1.gname}<br>
                            ￥${goods1.gprice}
                        </td>
                            <%--类别--%>
                        <td>
                                ${goods1.gcid}
                        </td>
                            <%--发布时间--%>
                        <td>
                                ${goods1.gtime}
                        </td>
                            <%--商品描述--%>
                        <td>
                            <c:if test="${goods1.gdetail==''}">
                                （无）
                            </c:if>
                            <c:if test="${goods1.gdetail!=''}">
                                ${goods1.gdetail}
                            </c:if>
                        </td>

                            <%-- 未卖出 --%>
                        <c:if test="${goods1.gtinyint==1}">
                            <td>未卖出</td>
                            <td><a href="goodsDetail?gid=${goods1.gid}">编辑</a><br></td>
                        </c:if>

                            <%-- 已卖出 --%>
                        <c:if test="${goods1.gtinyint==0}">
                            <td>已卖出</td>
                        </c:if>

                        <td colspan="2">
                                <%--删除--%>
                            <a class="deleteGoods" href="deleteGoods?gid=${goods1.gid}">删除</a>
                        </td>
                    </tr>
                    </c:forEach>
                    <script>
                        let deleteGoods = document.getElementsByClassName("deleteGoods");
                        for (let i = 0; i < deleteGoods.length; i++) {
                            deleteGoods[i].onclick = function () {
                                return confirm("确认删除此商品？");
                            }
                        }
                    </script>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

</body>
</html>
